#pragma once
#include "frame_pool.h"

class FramePoolFact
{
public:
	~FramePoolFact() = default;
	static FramePoolFact& GetInstance()
	{
		static FramePoolFact fac;
		return fac;
	}
	bool Init();
	bool Fini();
	bool CreatePool(size_t spliceSize, size_t spliceCnt, size_t expandingCnt);
	FramePtr BorrowFrame(size_t need);
	int BorrowFrames(std::vector<FramePtr>& frameVec, size_t need, size_t needCnt);
	void ReturnFrame(FramePtr frame)
	{
		ASSERT(frame != nullptr);
		frame->ReturnFrame();
	}
	void ReturnFrames(std::vector<FramePtr>& frameVec);
	std::string Audit();
private:
	FramePoolFact() = default;
	// poolList is sorted by sliceSize ascend
	std::vector<FramePoolPtr> poolList;
};